package ch10;

import java.util.Arrays;
import java.util.Scanner;

/**
 * @author oldliu
 * @since 1.0
 */
public class StrTest {
    public static void main(String[] args) {
//        String []name=new String[10];
//        System.out.println(Arrays.toString(name));
//        int i=0;
//        //找到空位置
//        if(name[i]==null){
//            name[i]="老吴";
//            i++;
//        }
        String []names=new String[]{"laowu","xiaozhang","laosong","xiaoma","oldwang"};
        System.out.println(Arrays.toString(names));
        Scanner in=new Scanner(System.in);
        System.out.println("删除谁？");
        String dname=in.next();
        for(int i=0;i<names.length;i++){
            if(names[i].equals(dname)){
                //找到要删除的人
                //从i，到最后，往前移动
                for(int j=i;j<names.length-1;j++){
                    names[j]=names[j+1];
                }
                names[names.length-1]=null;//!!!
                break;
            }
        }
        System.out.println(Arrays.toString(names));
    }
}
